using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Web.Core;
using System.Globalization;
using Web.Core.Objects;

public partial class AdminCP_AdminControls_TopMenu : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        HandleTopMenu();
        if (Session["Membership"] != null && !(Session["Membership"] as Member).IsAdministrator())
        {
            this.liSystem.Visible = false;
        }
    }

    protected void ImageButtonEn_Click(object sender, ImageClickEventArgs e)
    {
        Session["Language"] = GlobalStorage.Language.English;
        Resources.Lang.Culture = new CultureInfo("en");
        Response.Write("<script language=\"javascript\" type=\"text/javascript\">window.location = \"" + Request.Url.PathAndQuery + "\";</script>");
    }
    protected void ImageButtonVi_Click(object sender, ImageClickEventArgs e)
    {
        Session["Language"] = GlobalStorage.Language.Vietnamese;
        Resources.Lang.Culture = new CultureInfo("vi");
        Response.Write("<script language=\"javascript\" type=\"text/javascript\">window.location = \"" + Request.Url.PathAndQuery + "\";</script>");
    }

    void HandleTopMenu()
    {
        string tab = Utils.GetPageName(Request.Url.PathAndQuery);
        switch (tab.ToLower())
        {
            case "default":
                this.liDefault.Attributes["class"] = "active";
                break;
            case "products":
                this.liProducts.Attributes["class"] = "active";
                break;
            case "categories":
                this.liCategories.Attributes["class"] = "active";
                break;
            case "manufacturers":
                this.liManufacturers.Attributes["class"] = "active";
                break;
            case "members":
                this.liMembers.Attributes["class"] = "active";
                break;
            case "articles":
                this.liOrders.Attributes["class"] = "active";
                break;
            case "logs":
                this.liSystem.Attributes["class"] = "active";
                break;
            case "advertisements":
                this.liSystem.Attributes["class"] = "active";
                break;
            case "contact":
                this.liContact.Attributes["class"] = "active";
                break;
            case "currencies":
                this.liCurrencies.Attributes["class"] = "active";
                break;
            default:
                this.liDefault.Attributes["class"] = "active";
                break;
        }
    }

    protected void ImageButtonLogout_Click(object sender, ImageClickEventArgs e)
    {
        Session["Membership"] = null;
        Response.Redirect("Login.aspx");
    }
}
